Variational Problem with moving Boundaries